<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Hello World Html</title>
</head>
<body>
  <h2 class="title"></h2>
  <button class="btn">改变文本</button>

  <script>
    let message = 'Hello World'

    const titleEl = document.getElementsByClassName('title')[0]
    titleEl.innerHTML = message;

    const btnEl = document.getElementsByClassName('btn')[0]
    btnEl.addEventListener('click', e => {
      message = 'Hello React'
      titleEl.innerHTML = message
    })
  </script>
</body>
</html>